//
//  CZQAblutCoachHeadView.m
//  coachmanage
//
//  Created by 众拳科技 on 2018/3/22.
//  Copyright © 2018年 众拳科技. All rights reserved.
//

#import "CZQAblutCoachHeadView.h"

@implementation CZQAblutCoachHeadView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = CSWhiteColor;
  
        
        /**
         bg图片
         */
        UIImageView *bgView = [UIImageView new];
        bgView.userInteractionEnabled = YES;
        bgView.image = [UIImage imageNamed:@"t-bg"];
        [self addSubview:bgView];
        self.bgView = bgView;
        
        
        /**
         头像
         */
        UIButton *iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [iconBtn setImage:PlaceHold forState:UIControlStateNormal];
        iconBtn.layer.cornerRadius = 25;
        iconBtn.clipsToBounds = YES;
        [self.bgView addSubview:iconBtn];
        self.iconBtn = iconBtn;
        
        
        /**
         等级
         */
        UIButton *classBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        classBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 10, 3, 10);
        classBtn.layer.cornerRadius = 8;
        classBtn.clipsToBounds = YES;
        [classBtn setTitle:@"p1等级"];
        classBtn.backgroundColor = CSColorFromRGB(0xbd9e64);
        [classBtn setTitleColor:CSWhiteColor];
        classBtn.titleLabel.font = SmallFont;
        [self.bgView addSubview:classBtn];
        self.classBtn = classBtn;
        
        
        /**
         教练名
         */
        UILabel *nameLable = [UILabel new];
        nameLable.text = @"陈志强";
        nameLable.font = BigFont;
        nameLable.textColor = CSWhiteColor;
        [self.bgView addSubview:nameLable];
        self.nameLable = nameLable;
        
        /**
         学员个数
         */
        
        UIButton *stutyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [stutyBtn setImage:@"icon_student"];
        [self addSubview:stutyBtn];
        self.studyBtn = stutyBtn;
        
        UILabel *studyLable = [UILabel new];
        studyLable.text = @"学员案例41名";
        studyLable.userInteractionEnabled = YES;
        studyLable.font = MidBigFont;
        studyLable.textColor = BlackColor;
        [self addSubview:studyLable];
        self.studyLable = studyLable;
        
        UILabel *studyCountLable = [UILabel new];
        studyCountLable.text = @"已累计帮助41名学员";
        studyCountLable.font = SmallFont;
        studyCountLable.textColor = TextColor1;
        [self addSubview:studyCountLable];
        self.studyCountLable = studyCountLable;
        
        /**
         教练动态
         */
        UIButton *coachBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [coachBtn setImage:@"icon_coach"];
        [self addSubview:coachBtn];
        self.coachBtn = coachBtn;
        
        UILabel *coachLable = [UILabel new];
        coachLable.text = @"发现他的另一面";
        coachLable.font = SmallFont;
        coachLable.textColor = TextColor1;
        [self addSubview:coachLable];
        self.coachLable = coachLable;
        
        UILabel *coachCountLable = [UILabel new];
        coachCountLable.text = @"教练动态28";
        coachCountLable.userInteractionEnabled = YES;
        coachCountLable.font = MidBigFont;
        coachCountLable.textColor = BlackColor;
        [self addSubview:coachCountLable];
        self.coachCountLable = coachCountLable;
        
        UIView *sepView = [UIView new];
        sepView.backgroundColor = BackGroundColor;
        [self addSubview:sepView];
        self.sepView = sepView;
        
        
        [self setConstraints];
    }
    return self;
}

-(void)setConstraints
{
    
    
    /**
     bg图片
     */
    [self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.mas_equalTo(self);
        
    }];
    
    /**
     头像
     */
    [self.iconBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.bgView).offset(20);
        make.width.height.mas_equalTo(50);
        
    }];
    
    /**
     等级
     */
    [self.classBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.iconBtn.mas_bottom).offset(-8);
        make.height.mas_equalTo(16);
        
    }];
    
    /**
     教练名
     */
    [self.nameLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.bgView);
        make.top.mas_equalTo(self.classBtn.mas_bottom).offset(10);
        make.height.mas_equalTo(25);
        make.bottom.mas_equalTo(self.bgView).offset(-20);
        
    }];
    
    
    /**
     学员个数
     */
    
    [self.studyBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.bgView.mas_bottom).offset(20);
        make.left.mas_equalTo(self).offset(20);
        
    }];
    
    [self.studyLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.studyBtn);
        make.left.mas_equalTo(self.studyBtn.mas_right).offset(5);
        make.right.mas_equalTo(self.coachBtn.mas_left).offset(-10);
    }];
    
    [self.studyCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.studyLable.mas_bottom).offset(5);
        make.left.mas_equalTo(self.studyLable);
        make.right.mas_equalTo(self.studyLable);
    }];
    
    /**
     叫练
     */
    
    [self.coachBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.bgView.mas_bottom).offset(20);
        make.left.mas_equalTo(self.mas_centerX).offset(5);
        
    }];
    
    [self.coachCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.coachBtn);
        make.left.mas_equalTo(self.coachBtn.mas_right).offset(5);
//        make.right.mas_equalTo(self).offset(-10);
    }];
    
    [self.coachLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.coachCountLable.mas_bottom).offset(5);
        make.left.mas_equalTo(self.coachCountLable);
//        make.right.mas_equalTo(self.coachCountLable);
        make.bottom.mas_equalTo(self.studyCountLable);
    }];
    
    [self.sepView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.studyCountLable.mas_bottom).offset(20);
        make.left.width.bottom.mas_equalTo(self);
        make.height.mas_equalTo(10);
    }];
    
}
        
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
